#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
const int N = 2005;

string s, t;
int n, m;
int dp[N][N];
int dfs(int i, int j) {
  if (i == n && j == m) return 0;
  if (i == n) return m - j;
  if (j == m) return n - i;
  if (dp[i][j] != -1) return dp[i][j];
  if (s[i] == t[j])
    dp[i][j] = dfs(i + 1, j + 1);
  else
    dp[i][j] = 1 + min({dfs(i + 1, j + 1), dfs(i, j + 1), dfs(i + 1, j)});
  return dp[i][j];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> s >> t;
  n = s.size(), m = t.size();
  memset(dp, -1, sizeof(dp));
  cout << dfs(0, 0);
  return 0;
}